//方法一 递归
bool isUnivalTree(struct TreeNode* root)
{
    if(root == NULL)
    {
        return true;
    }
    if(root->left && root->left->val != root->val)
    {
        return false;
    }
    if(root->right && root->right->val != root->val)
    {
        return false;
    }
    return isUnivalTree(root->left) && isUnivalTree(root->right);
}

//方法二 遍历二叉树
bool _isUnivalTree(struct TreeNode* root, int val)
{
    if(root == NULL)
    {
        return true;
    }
    if(root->val != val)
    {
        return false;
    }
    return _isUnivalTree(root->left, val) && _isUnivalTree(root->right, val);
}
bool isUnivalTree(struct TreeNode* root)
{
    return _isUnivalTree(root, root->val);
}